package controller

import (
	"Family/common"
	"fmt"

	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)

func GinUpdateInfo(ctx *gin.Context) {

	db := common.Connect()
	defer db.Close()

	var data common.Info
	ctx.ShouldBindBodyWith(&data, binding.JSON)
	fmt.Println(data)

	if Isidexists(db, data.Id) == false {
		fmt.Println("用户不存在")
		ctx.JSON(200, gin.H{
			"msg": "用户不存在, 修改失败",
		})
		return
	}
	//数据验证

	common.UpdataInfo(db, data)

	ctx.JSON(200, "修改成功")

}
